<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>任务组管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			//$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				},
				rules:{
					name:{
						remote: {
						    url: $("#ctx").val()+"/pro/taskGroup/getByName",     //后台处理程序
						    type: "post",               //数据发送方式
						    dataType: "json",           //接受数据格式   
						    data: {                     //要传递的数据
						        name: function() {
						            return $("#name").val();
						        },
						        id: function(){
						        	return $("#id").val();
						        },
						        projectId:function(){
						        	return $("#projectId").val();
						        }
						    }
						}
					}
				},
				messages:{
					name:{
						remote:"该任务组名称已存在！"
					}
				}
			});
		});
		function submitForm(){                                      //子窗体页面的保存数据方法 通过ajax
			var flag = false;
            if($("#inputForm").valid()){
                var url = "${ctx}/pro/taskGroup/save";
                $.ajax({
                    type: 'POST',
                    url : url,
                    async:false,
                    data: $('#inputForm').serialize(),             //获取表单数据
                    success : function(data) {
                    	    flag = true;
                            alert("保存成功");
                            parent.$('#btn').click();
                            parent.$.jBox.close(true);
                            
                            /* window.parent.page();                                     //调用父窗体方法，当关闭子窗体刷新父窗体
                            window.parent.window.jBox.close(); */            //关闭子窗体
                    },
                    error : function(data){
                    	alertx("无权限");
                    }
                });
            }
            return flag;
        }
	</script>
</head>
<body>
	<%-- <ul class="nav nav-tabs">
		<li><a href="${ctx}/pro/taskGroup/?project.id=${taskGroup.project.id}">任务组列表</a></li>
		<li class="active"><a href="${ctx}/pro/taskGroup/form?id=${taskGroup.id}&project.id=${taskGroup.project.id}">任务组<shiro:hasAnyPermissions name="pro:taskGroup:edit,pro:taskGroup:create">${not empty taskGroup.id?'修改':'添加'}</shiro:hasAnyPermissions></a></li>
	</ul><br/> --%>
	<form:form id="inputForm" modelAttribute="taskGroup" action="${ctx}/pro/taskGroup/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<input type="hidden" id="ctx" value="${ctx}"/>
		<input id="projectId" name="project.id" value="${taskGroup.project.id}" type="hidden"/>
		<sys:message content="${message}"/>		
		<div class="control-group">
			<label class="control-label">任务组名称：</label>
			<div class="controls">
				<input id="name" name="name" value="${taskGroup.name}" class="input-xlarge required"/>
			</div>
		</div>
		<%-- <div class="control-group">
			<label class="control-label">所属项目id：</label>
			<div class="controls">
				<form:input path="project.id" htmlEscape="false" maxlength="64" class="input-xlarge required"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div> --%>
		<div class="control-group">
			<label class="control-label">备注信息：</label>
			<div class="controls">
			<%-- <form:hidden path="name" htmlEscape="false" maxlength="255" class="input-xlarge"/> --%>
			</div>
		</div>
		<div>
		<tags:ckfinder input="name" type="files" uploadPath="/test "/>
				<form:textarea path="remarks" htmlEscape="false" rows="4" maxlength="255" class="input-xxlarge "/>
		</div>
		<%-- <div class="form-actions">
			<shiro:hasPermission name="pro:taskGroup:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div> --%>
	</form:form>
</body>
</html>